#pragma once

#include "GameStd.h"
#include <OgreVector3.h>

class SteeringBehaviors;

class AutoObject : public IMovingObject
{
public:

	AutoObject();
	~AutoObject();

	//Inherited from IGameManager
	void Initialize();
	void UpdateStarted(const Ogre::FrameEvent& gameTime);
	void UpdateEnded(const Ogre::FrameEvent& gameTime);
	void Cleanup();

	//Inherited from IObject
	void Draw();
	bool HandleMessage(int message);
	Ogre::Vector3 GetPosition();
	void SetPostion(Ogre::Vector3 pos);
	double GetBRadius();
	void SetBRadius(double r);
	int GetID();
	void SetID(int id);
	bool IsTagged();
	void Tag();
	void UnTag();
	Ogre::Vector3 GetScale();
	void SetScale(Ogre::Vector3 nScale);
	void SetScale(double nScale);
	ObjectType GetObjectType();
	void SetObjectType(ObjectType nType);
	void Write(std::ostream& os);
	void Read(std::istream& is);
	double TimeElapsed();
	void SetName(Ogre::String nName);
	Ogre::String GetName();
	
	//Inherited from IMovingObject
	Ogre::Vector3 GetVelocity();
	void SetVelocity(Ogre::Vector3 nVelocity);
	double GetMass();
	void SetMass(double nMass);
	Ogre::Vector3 GetPerp();
	double GetMaxSpeed();
	void SetMaxSpeed(double nSpeed);
	double GetMaxForce();
	void SetMaxForce(double nForce);
	void SetAppliedForce(Ogre::Vector3 nForce);
	Ogre::Vector3 GetAppliedForce();
	bool IsSpeedMaxedOut();
	double Speed();
	double SpeedSq();
	Ogre::Vector3 GetHeading();
	void SetHeading(Ogre::Vector3 nHeading);
	void SetHeading(int xHeading, int yHeading, int zHeading);
	bool RotateHeadingToFacePosition(Ogre::Vector3 target);
	double GetMaxTurnRate();
	void SetMaxTurnRate(double nRate);
	Ogre::Vector3 GetCurrentAccel();
	void SetCurrentAccel(Ogre::Vector3 nAccel);
	void SetCurrentAccel(double xAccel, double yAccel, double zAccel);

	//Unique to AutoObject
	SteeringBehaviors* Steering();
	Ogre::Vector3 SmoothedHeading();
	bool isSmoothingOn();
	void SmoothingOn();
	void SmoothingOff();
	void ToggleSmoothing();
	

private:
	int m_ID;					//Unique, assigned by ObjectManager

	ObjectType m_ObjectType;	//A Auto object is designated by 
								//Autonomous, of the ObjectType enum
								//in IObject
	bool m_Tag;					

	Ogre::Vector3 m_Pos;		//Indicates current position described by
								//a 3D vector

	Ogre::Vector3 m_Scale;		//Indicates the current scale described by
								//a 3D vector
	
	double m_BoundingRadius;

	Ogre::Vector3 m_Velocity;	//The current velocity described by a 3D 
								//vector

	Ogre::Vector3 m_Heading;	//The current heading described by a 3D 
								//vector

	Ogre::Vector3 m_Perp;		//A unit vector perpendicular 
								//to the heading

	Ogre::Vector3 m_Acceleration;

	Ogre::Vector3 m_AppliedForce;

	double m_Mass;				

	double m_MaxSpeed;			

	double m_MaxForce;

	double m_MaxTurnRate;

	SteeringBehaviors* m_Steering;

	Ogre::Vector3 m_HeadingSmoother;

	Ogre::Vector3 m_SmoothedHeading;

	bool m_SmoothingOn;

	double m_TimeElapsed;

	Ogre::String m_Name;

};